/*
 * AssessmentFacade.java
 *
 * Created on 24 April 2008, 22:08
 */

package unilearn.facade;

import java.sql.SQLException;
import java.util.Vector;

import javax.naming.NamingException;

import unilearn.da.DAAssessment;
import unilearn.domain.Assessment;

/**
 * @author Ben Morall, 4158768
 * @author Yin Zhang, 5393558
 * @version 0.1, 24 April 2008, did wrong class, optional content, blm
 * @version 0.2, 03 May 2008, initial creation
 */
public class AssessmentFacade
{
	public static Assessment getByAssessmentID(long assessmentID) throws SQLException,
		NamingException
	{
		if (assessmentID < 0)
			throw new IllegalArgumentException("assessmentID is invalid: " + assessmentID);

		return DAAssessment.getAssessmentByID(assessmentID);
	}

	public static Assessment getBySubmissionID(long submissionID) throws SQLException,
		NamingException
	{
		return DAAssessment.getAssessmentBySubmission(submissionID);
	}

	public static Vector<Assessment> getByStaffID(String staffID) throws SQLException,
		NamingException
	{
		return DAAssessment.getAssessmentByStaff(staffID);
	}

	public static long createNewAssessment(Assessment assessment) throws SQLException,
		NamingException
	{
		return DAAssessment.insertAssessment(assessment);
	}

	public static void updateAssessment(Assessment assessment) throws SQLException,
		NamingException
	{
		if (assessment.getAssessmentID() == -1)
			throw new IllegalArgumentException("assessment does not exist in database");
		DAAssessment.updateAssessment(assessment);
	}
}